#include "affiliate_bar.h"

affiliate_bar *affiliate_bar::createABar(screen *parent,glm::vec2 size,Anchor anchor)
{
    auto bar = new affiliate_bar();
    bar->init();
    bar->setAnchor(anchor);
    bar->setSize(size);
    if(parent){
        parent->addChild(bar);
        bar->parent_ = parent;
    } 
    return bar;
}

void affiliate_bar::render()
{
    auto pos = parent_->getRenderPosition() + offset_;
    if(percent_>0.7){
        game_.renderHbar(pos, size_, percent_, color_high);
    }else if(percent_>0.3){
        game_.renderHbar(pos, size_, percent_, color_mid);
    }else{
        game_.renderHbar(pos, size_, percent_, color_low);
    }
}